package socketdemo7;

import java.io.BufferedWriter;
import java.io.IOException;
import java.io.InputStream;
import java.io.OutputStreamWriter;
import java.net.ServerSocket;
import java.net.Socket;

public class ServerDemo {
    public static void main(String[] args) throws IOException {
        ServerSocket ss = new ServerSocket(10000);
        Socket s = ss.accept();
        InputStream is = s.getInputStream();
        int b;
        while ((b = is.read()) != -1) {
            System.out.println((char) b);
        }
        /*OutputStream os = s.getOutputStream();
        os.write("你是谁".getBytes());*/

        System.out.println("看看我执行了吗？");
        BufferedWriter bw = new BufferedWriter(new OutputStreamWriter(s.getOutputStream()));
        bw.write("你是谁？");
        bw.newLine();
        bw.flush();

        bw.close();
        is.close();
        s.close();
        ss.close();
    }
}
